package com.lingkang.sales.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lingkang.sales.common.val.HttpCode;
import com.lingkang.sales.data.dto.ResponsePageResult;
import com.lingkang.sales.data.mapper.SaGroupMapper;
import com.lingkang.sales.data.vo.GroupVo;
import com.lingkang.sales.service.GroupService;
import com.lingkang.sales.service.UserService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author linke
 * @date 2020/11/19 22:19
 * @description
 */
@Service
public class GroupServiceImpl implements GroupService {

  @Autowired
  private SaGroupMapper saGroupMapper;
  @Autowired
  private UserService userService;


  @Override
  public ResponsePageResult getGroup(String comCode, String groupName, String groupCode, Integer page, Integer size) {
    String userUpperCode = userService.getLoginUser().getUpdateCode();
    Page pages = PageHelper.startPage(page, size);
    List<GroupVo> res = saGroupMapper.get(comCode, groupName, groupCode, userUpperCode);
    return new ResponsePageResult(HttpCode.OK,page,size,pages.getTotal(),res);
  }
}
